/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package EntityBeans;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author Keith Augustsson
 */
@Entity
@Table(name = "flightinstances")
@NamedQueries({
    @NamedQuery(name = "Flightinstances.findAll", query = "SELECT f FROM Flightinstances f"),
    @NamedQuery(name = "Flightinstances.findByFlight", query = "SELECT f FROM Flightinstances f WHERE f.flightinstancesPK.flight = :flight"),
    @NamedQuery(name = "Flightinstances.findByDepDate", query = "SELECT f FROM Flightinstances f WHERE f.flightinstancesPK.depDate = :depDate"),
    @NamedQuery(name = "Flightinstances.findByArrDate", query = "SELECT f FROM Flightinstances f WHERE f.flightinstancesPK.arrDate = :arrDate"),
    @NamedQuery(name = "Flightinstances.findByAvailableSeats", query = "SELECT f FROM Flightinstances f WHERE f.availableSeats = :availableSeats")})
public class Flightinstances implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected FlightinstancesPK flightinstancesPK;
    @Column(name = "availableSeats")
    private Integer availableSeats;

    private Integer fare;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date depTime;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date arrTime;
    private String airline;
    private String depAirport;
    private String arrAirport;

    public Flightinstances() {
    }

    public Flightinstances(FlightinstancesPK flightinstancesPK) {
        this.flightinstancesPK = flightinstancesPK;
    }

    public Flightinstances(String flight, Date depDate, Date arrDate) {
        this.flightinstancesPK = new FlightinstancesPK(flight, depDate, arrDate);
    }

    public Flightinstances(String flight, Date depDate, Date arrDate, int availableSeats, int fare, Date depTime, Date arrTime, String airline, String depAirport, String arrAirport) {
        this.flightinstancesPK = new FlightinstancesPK(flight, depDate, arrDate);
        this.airline = airline;
        this.arrAirport = arrAirport;
        this.arrTime = arrTime;
        this.availableSeats = availableSeats;
        this.depAirport = depAirport;
        this.fare = fare;
    }

    public FlightinstancesPK getFlightinstancesPK() {
        return flightinstancesPK;
    }

    public void setFlightinstancesPK(FlightinstancesPK flightinstancesPK) {
        this.flightinstancesPK = flightinstancesPK;
    }

    public Integer getAvailableSeats() {
        return availableSeats;
    }

    public void setAvailableSeats(Integer availableSeats) {
        this.availableSeats = availableSeats;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (flightinstancesPK != null ? flightinstancesPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Flightinstances)) {
            return false;
        }
        Flightinstances other = (Flightinstances) object;
        if ((this.flightinstancesPK == null && other.flightinstancesPK != null) || (this.flightinstancesPK != null && !this.flightinstancesPK.equals(other.flightinstancesPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "EntityBeans.Flightinstances[flightinstancesPK=" + flightinstancesPK + "]";
    }
}
